<template>
  <div style="padding: 20px">
    <el-card>
      <!-- 主页面-->
      <div v-show=" scene === 1 ">
        <el-button type="primary" size="mini" style="margin-right:10px" @click="scene = 5;getAllCommandOfCompany()">
          所有操作命令
        </el-button>
        <el-button type="primary" size="mini" @click="selectmode">命令模板</el-button>
        <el-input
          v-model="selectname"
          placeholder="请输入设备名称"
          style="margin-left: 200px;width: 200px;margin-right:10px"
        />
        <el-button type="primary" icon="el-icon-search" style="margin:10px 0px" @click="select">搜索</el-button>
        <el-button type="primary" icon="el-icon-plus" style="margin:10px 0px;float: right" @click="showDialog">
          添加设备
        </el-button>
        <el-table style="width: 100%" border :data="list">
          <el-table-column type="index" prop="prop" label="序号" width="80px" align="center" />
          <el-table-column prop="name" label="名称" width="width" />
          <el-table-column prop="id" label="编号" width="70px" />
          <el-table-column prop="ip" label="IP" width="width" />
          <el-table-column prop="port" label="端口" width="width" />
          <el-table-column label="是否在线" width="70px">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-tag v-if="row.isonline" type="success">在线</el-tag>-->
            <!--              <el-tag v-else type="info">离线</el-tag>-->
            <!--            </template>-->
          </el-table-column>
          <el-table-column prop="lastlogintime" label="最新响应时间" min-width="100">
            <template slot-scope="{row}">
              {{ (new Date(row.lastlogintime)).Format('yyyy-MM-dd hh:mm:ss') }}
            </template>
          </el-table-column>
          <el-table-column prop="location" label="地理位置" width="width" />
          <el-table-column prop="command" label="设备命令" width="80px">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="primary" size="mini" @click="getDeviceId(row)">查看</el-button>-->
            <!--            </template>-->
          </el-table-column>
          <el-table-column prop="description" label="备注" width="width" />
          <el-table-column prop="prop" label="操作" width="width">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="warning" icon="el-icon-edit" size="mini" @click="device.Visible=true;device_id=row.id" />-->
            <!--              <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteEqu(row)" />-->
            <!--            </template>-->
          </el-table-column>
        </el-table>
      </div>
      <!-- 命令模板-->
      <div>
        <equipop v-show=" scene === 2 " ref="child1" @changeScene="changeScene" />
      </div>
      <!--添加设备界面-->
      <div>
        <crdu v-show=" scene === 3 " ref="crdu" :companyid="companyid" @changeScene="changeScene" />
      </div>
      <!-- 命令页面-->
      <div v-show=" scene === 4 ">
        <el-button type="primary" @click="changeScene(1)">返回</el-button>
        <el-button type="primary" icon="el-icon-plus" @click="addCommand">添加命令</el-button>
        <el-button type="danger" icon="el-icon-delete" style="float: right" @click="deleteBatch(row)">批量删除
        </el-button>
        <el-table :data="commandList">
          <el-table-column type="index" prop="prop" label="序号" width="80" />
          <el-table-column property="url" label="URL" width="" />
          <el-table-column property="description" label="描述" width="" />
          <el-table-column prop="prop" label="管理人员" width="">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="primary" icon="el-icon-search" size="mini" @click="getUser(row)">查看</el-button>-->
            <!--            </template>-->
          </el-table-column>
          <el-table-column prop="prop" label="操作" width="80px">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteCom(row)" />-->
            <!--            </template>-->
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top: 20px; text-align: center"
          :current-page.sync="commandPage"
          :page-count="7"
          :page-sizes="[3,5,10]"
          :page-size.sync="commandLimit"
          layout=" prev, pager, next, jumper,->,total,sizes"
          :total="total"
          @current-change="getCommand"
          @size-change="handleCommandSizeChange"
        />
      </div>
      <!--设备管理第一级查看里的添加命令-->
      <div>
        <el-dialog title="添加命令" :visible.sync="dialogFlag">
          <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选
          </el-checkbox>
          <div style="margin: 15px 0;" />
          <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in addList" :key="city.id" :label="city.id">
              {{ city.URL }}-{{ city.method }}-{{ city.description }} <br>
            </el-checkbox>
          </el-checkbox-group>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFlag = false">取 消</el-button>
            <el-button type="primary" @click="addOrderList(row)">确 定</el-button>
          </div>
        </el-dialog>
      </div>
      <!--设备管理第一级查看里的批量删除按钮的弹窗-->
      <div>
        <el-dialog title="批量删除操作命令" :visible.sync="dialogFlag1">
          <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选
          </el-checkbox>
          <div style="margin: 15px 0;" />
          <el-checkbox-group v-model="checkedDelete" @change="handleCheckedCitiesChange">
            <el-checkbox v-for="city in addList" :key="city.id" :label="city.id">
              {{ city.URL }}-{{ city.method }}-{{ city.description }} <br>
            </el-checkbox>
          </el-checkbox-group>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFlag1 = false">取 消</el-button>
            <el-button type="primary" @click="deleteOrderList(row)">确 定</el-button>
          </div>
        </el-dialog>
      </div>
      <el-dialog title="该设备此条命令管理人员" :visible.sync="dialogTableVisible">
        <el-button type="primary" size="mini" icon="el-icon-plus" @click="addControler">添加</el-button>
        <el-table :data.sync="userList">
          <el-table-column type="index" prop="prop" label="序号" width="80" />
          <el-table-column property="name" label="姓名" width="" />
          <el-table-column property="email" label="邮箱" width="200" />
          <el-table-column property="role" label="用户角色" />
          <el-table-column label="操作">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="danger" size="mini" icon="el-icon-delete" @click="deleteUser(row)" />-->
            <!--            </template>-->
          </el-table-column>
        </el-table>
      </el-dialog>
      <el-dialog title="添加此设备该命令管理人员" :visible.sync="dialogAddControl">
        <el-table :data="controlCities">
          <el-table-column type="index" prop="prop" label="序号" width="80px" />
          <el-table-column prop="name" label="姓名" width="width" />
          <el-table-column prop="role" label="角色" width="width" />
          <el-table-column>
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button v-if="iscontrol" type="primary" size="mini" @click="addControllerList(row)">-->
            <!--                添加-->
            <!--              </el-button>-->
            <!--              <el-tag v-else type="success">-->
            <!--                已添加为管理员-->
            <!--              </el-tag>-->
            <!--            </template>-->
          </el-table-column>
        </el-table>
      </el-dialog>
      <!--  公司所有命令  -->
      <div v-show="scene === 5">
        <el-button type="primary" @click="scene = 1">返回</el-button>
        <el-button type="primary" @click="commandOfCompany.centerDialogVisible = true">添加命令</el-button>

        <!--添加命令弹窗-->
        <el-dialog title="添加命令" :visible.sync="commandOfCompany.centerDialogVisible" width="40%" center>
          <span slot="footer" class="dialog-footer">
            <el-form :model="commandOfCompany.command" :rules="commandOfCompany.rule">
              <el-form-item label="URL" prop="url">
                <el-input v-model="commandOfCompany.command.url" />
              </el-form-item>
              <el-form-item label="方法" prop="method">
                <el-select v-model="commandOfCompany.command.method">
                  <el-option value="GET">GET</el-option>
                  <el-option value="POST">POST</el-option>
                  <el-option value="PUT">PUT</el-option>
                  <el-option value="DELETE">DELETE</el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="描述" prop="description">
                <el-input v-model="commandOfCompany.command.description" />
              </el-form-item>
            </el-form>
            <el-button
              @click="commandOfCompany.centerDialogVisible = false;
                      commandOfCompany.command.description = null;
                      commandOfCompany.command.url = null"
            >取 消</el-button>
            <el-button type="primary" @click="addCommandOfCompany()">确 定</el-button>
          </span>
        </el-dialog>
        <!--修改命令弹窗-->
        <el-dialog title="修改命令" :visible.sync="commandOfCompany.updateVshow" width="40%" center>
          <span slot="footer" class="dialog-footer">
            <el-form :model="commandOfCompany.command" :rules="commandOfCompany.rule">
              <el-form-item label="URL" v-bind="commandOfCompany.cur_command_url">
                {{ commandOfCompany.cur_command_url }}
              </el-form-item>
              <el-form-item label="描述" prop="description">
                <el-input v-model="commandOfCompany.command.description" />
              </el-form-item>
            </el-form>
            <el-button
              @click="commandOfCompany.updateVshow = false;
                      commandOfCompany.command.description = null;
                      commandOfCompany.command.url = null"
            >取 消</el-button>
            <el-button type="primary" @click="updateCommandOfCompany(row)">确 定</el-button>
          </span>
        </el-dialog>
        <!--公司所有设备命令列表-->
        <el-table :data="commandOfCompany.list">
          <el-table-column type="index" prop="prop" label="序号" width="80" />
          <el-table-column property="url" label="URL" width="" />
          <el-table-column prop="method" label="方法" min-width="80" />
          <el-table-column property="description" label="描述" width="" />
          <el-table-column prop="prop" label="操作" width="">
            <!--            <template slot-scope="{row,$index}">-->
            <!--              <el-button type="danger" icon="el-icon-edit" size="mini" @click="changeuc(row)" />-->
            <!--              <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteCommandOfCompany(row.id)" />-->
            <!--            </template>-->
          </el-table-column>
        </el-table>
        <el-pagination
          style="text-align: center"
          :current-page.sync="commandOfCompany.current"
          :page-sizes="[1,3, 5,7, 10,15]"
          :page-size.sync="commandOfCompany.pagesize"
          layout="prev, pager, next, jumper,->,sizes,total"
          @current-change="getAllCommandOfCompany()"
          @size-change="getAllCommandOfCompany()"
        />
      </div>
      <!--修改设备信息弹窗-->
      <el-dialog title="修改设备信息" :visible.sync="device.Visible" width="40%" center>
        <span slot="footer" class="dialog-footer">
          <el-form :model="device.from">
            <el-form-item label="设备名">
              <el-input v-model="device.from.name" />
            </el-form-item>
            <el-form-item label="IP">
              <el-input v-model="device.from.ip" />
            </el-form-item>
            <el-form-item label="端口">
              <el-input v-model="device.from.port" />
            </el-form-item>
            <el-form-item label="位置">
              <el-input v-model="device.from.location" />
            </el-form-item>
            <el-form-item label="备注">
              <el-input v-model="device.from.description" />
            </el-form-item>
          </el-form>
          <el-button
            @click="device.Visible = false;
                    device.from.id= null;
                    device.from.name= null;
                    device.from.ip= null;
                    device.from.port= null;
                    device.from.location= null;
                    device.from.description= null"
          >取 消</el-button>
          <el-button type="primary" @click="updateDevice()">确 定</el-button>
        </span>
      </el-dialog>
    </el-card>
  </div>

</template>

<script setup>
// import equipop from './equipop'
// import crdu from './crdu'

export default {
  name: 'Index',
  components: {
    // equipop,
    // crdu
  },
  data() {
    return {
      device: {
        from: {
          id: null,
          name: null,
          ip: null,
          port: null,
          location: null,
          description: null
        },
        Visible: false
      },
      commandOfCompany: {
        list: [],
        pagesize: 10,
        current: 1,
        centerDialogVisible: false, // 添加命令的弹窗是否弹出
        updateVshow: false, // 修改命令的弹窗是否弹出
        command: { // 表单
          url: '',
          method: null,
          description: ''
        },
        cur_command_id: null,
        cur_command_url: null,
        cur_command_method: null,
        cur_company_id: null,
        rule: { // 表单规则
          url: [{ required: true, message: '请输入命令的URL', trigger: 'blur' }],
          description: [{ required: true, message: '请输入命令的描述', trigger: 'blur' }]
        }
      },
      // 下面是添加命令复选框
      checkAll: false,
      checkedCities: [],
      controlCities: [],
      isIndeterminate: true,
      iscontrol: true,
      addList: [],
      // 下面时批量删除复选框
      checkedDelete: [],
      // 单个删除的时候用的数组
      singleDel: [],
      // 添加命令的表单的状态展示flag，默认为不展示
      dialogFlag: false,
      dialogFlag1: false,
      list: [],
      selectname: '',
      isshow: true,
      scene: 1,
      limit: 10,
      page: 1,
      total: 30,
      dialogTableVisible: false,
      dialogAddControl: false,
      userList: [],
      // 某设备所有命令
      commandList: [],
      commandLimit: 3,
      commandPage: 1,
      device_id: 0,
      command_id: 0,
      command: {},
      companyid: this.$route.query.company_id
    }
  },
  mounted() {
    this.getEquList()
  },
  methods: {
    // 添加管理人员
    addControler() {
      this.dialogAddControl = true
      this.$axios.get(this.PlatformBaseURL + '/device/auth/getMAnofCommandCanAdd', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          command_id: this.command_id,
          device_id: this.device_id
        }
      }).then((res) => {
        if (res.code === 200) {
          this.controlCities = res.data
        }
      })
    },
    addControllerList(row) {
      // alert('看到这个说明按钮有反应但是函数还没有')
      this.dialogAddControl = false
      this.$axios.post(this.PlatformBaseURL + '/device/auth/addpeople', {
        device_id: this.device_id,
        command_id: this.command_id,
        user_id: row.id
      }, {
        headers: {
          satoken: window.localStorage.getItem('token')
        }
      }).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '添加成功'
          })
          this.getUser(this.command)
        } else {
          alert(res.msg)
        }
      })
    },
    // 变换页面
    changeScene(scene) {
      this.scene = scene
    },
    // 按名称查询设备
    select() {
      if (this.selectname === '') {
        alert('所要查询的设备名称为空')
      } else {
        this.$axios.get(this.PlatformBaseURL + '/device/query',
          {
            headers: {
              satoken: window.localStorage.getItem('token')
            },
            params: {
              pagesize: this.limit,
              current: 1,
              name: this.selectname,
              company_id: this.$route.query.company_id
            }
          }
        ).then((res) => {
          // console.log(res)
          this.list = res.data
        })
      }
    },
    // 查看命令模板
    selectmode() {
      this.scene = 2
      this.$refs.child1.getAllList()
    },
    // 添加修改窗口
    showDialog() {
      this.scene = 3
    },
    // handleCommandCurrent(page) {
    //   this.commandPage = page
    //     this.getCommand()
    // },
    // 命令页面条数变化
    handleCommandSizeChange(limit) {
      this.commandLimit = limit
      this.getCommand()
    },
    // 设备页面变化
    handleSizeChange(limit) {
      this.limit = limit
      this.getEquList()
    },
    // 获取设备列表
    getEquList(page = 1) {
      this.page = page
      this.$axios.get(this.PlatformBaseURL + '/company/getalldevice',
        {
          headers: {
            satoken: window.localStorage.getItem('token')
          },
          params: {
            company_id: this.$route.query.company_id
          }
        }).then((res) => {
        // console.log(res)
        this.list = res.data
      })
    },
    // 删除设备
    deleteEqu(row) {
      this.$axios.post(this.PlatformBaseURL + '/device/delete',
        {
          id: row.id
        }, {
          headers: {
            satoken: window.localStorage.getItem('token')
          }
        }).then((res) => {
        // console.log(res)
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.getEquList()
        } else {
          alert('删除失败！')
        }
      })
    },
    getDeviceId(row) {
      this.device_id = row.id
      this.scene = 4
      this.getCommand()
    },
    // 查看该设备所有命令
    getCommand(page = 1) {
      this.commandPage = page
      this.$axios.get(this.PlatformBaseURL + '/device/auth/getone', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          pagesize: this.commandLimit,
          current: this.commandPage,
          device_id: this.device_id
        }
      }).then((res) => {
        // console.log(res)
        this.commandList = res.data
      })
    },
    // 添加命令按钮的点击事件
    addCommand() {
      // 获取当前可以获得到的全部操作命令
      this.$axios.get(this.PlatformBaseURL + '/device/auth/getCommandCanAdd', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          device_id: this.device_id
        }
      }).then((res) => {
        // alert(111)
        // console.log(res)
        // this.opList = res.data
        this.addList = res.data
      })
      this.dialogFlag = true
    },
    // 添加命令的表单的(确定按钮)的点击事件
    addOrderList(row) {
      this.dialogFlag = false
      // 获取当前可以获得到的全部操作命令
      this.$axios.post(this.PlatformBaseURL + '/device/auth/add', {
        device_id: this.device_id,
        URLS: this.checkedCities
      },
      {
        headers: {
          satoken: window.localStorage.getItem('token')
        }
      }).then((res) => {
        if (res.code === 200) {
          // this.list = res.data
          this.$message({
            message: '为本设备添加命令成功',
            type: 'success'
          })
          this.getCommand(1)
        }
      })
    },
    // 删除单个操作命令
    deleteCom(row) {
      // 获取当前可以获得到的全部操作命令
      this.$axios.get(this.PlatformBaseURL + '/device/command/getall', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          pagesize: this.limit,
          current: 1
        }
      }).then((res) => {
        // alert(111)
        // console.log(res)
        // this.opList = res.data
        this.addList = res.data
      })
      this.singleDel[0] = row.id
      // 发送删除操作命令的请求
      this.$axios.post(this.PlatformBaseURL + '/device/auth/delete', {
        device_id: this.device_id,
        URLS: this.singleDel
      },
      {
        headers: {
          satoken: window.localStorage.getItem('token')
        }
      }).then((res) => {
        if (res.code === 200) {
          // this.list = res.data
          this.$message({
            message: '此操作命令删除成功',
            type: 'success'
          })
          this.getCommand(1)
        }
      })
    },
    // 批量删除操作命令按钮
    deleteBatch(row) {
      // 获取当前可以获得到的全部操作命令
      this.$axios.get(this.PlatformBaseURL + '/device/command/getall', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          pagesize: this.limit,
          current: 1
        }
      }).then((res) => {
        // alert(111)
        // console.log(res)
        // this.opList = res.data
        this.addList = res.data
      })
      this.dialogFlag1 = true
    },
    // 批量删除的弹窗的确定按钮
    deleteOrderList(row) {
      this.dialogFlag1 = false
      // 发送批量删除操作命令的请求
      this.$axios.post(this.PlatformBaseURL + '/device/auth/delete', {
        device_id: this.device_id,
        URLS: this.checkedDelete
      }, {
        headers: {
          satoken: window.localStorage.getItem('token')
        }
      }).then((res) => {
        if (res.code === 200) {
          // this.list = res.data
          this.$message({
            message: '批量删除操作命令删除成功',
            type: 'success'
          })
          this.getCommand(1)
        }
      })
    },
    getUser(row) {
      this.command = row
      this.command_id = row.id
      this.dialogTableVisible = true
      this.$axios.get(this.PlatformBaseURL + '/device/auth/getallpeople', {
        headers: {
          satoken: window.localStorage.getItem('token')
        },
        params: {
          device_id: this.device_id,
          command_id: row.id
        }
      }).then((res) => {
        this.userList = res.data
      })
    },
    // 删除该设备该命令管理人员
    deleteUser(row) {
      this.$axios.post(this.PlatformBaseURL + '/device/auth/deletepeople', {
        device_id: this.device_id,
        command_id: this.command_id,
        user_id: row.id
      }, {
        headers: {
          satoken: window.localStorage.getItem('token')
        }
      }).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '删除成功'
          })
          this.getUser(this.command)
        } else {
          alert('删除失败！')
        }
      })
    },
    // 下面的是多选框的自定义函数
    handleCheckAllChange(val) {
      this.checkedCities = val ? this.addList : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.addList.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.addList.length
    },
    handleControlCheckAllChange(val) {
      this.controlCheckedCities = val ? this.controlCities : []
      this.isControlIndeterminate = false
    },
    handleControlCheckedCitiesChange(value) {
      const checkedCount = value.length
      this.ControlCheckAll = checkedCount === this.controlCities.length
      this.isControlIndeterminate = checkedCount > 0 && checkedCount < this.controlCities.length
    },
    // 获取该公司所有命令
    getAllCommandOfCompany() {
      this.commandOfCompany.list = null
      this.$axios.get(this.PlatformBaseURL + '/device/command/getall',
        {
          headers: {
            satoken: window.localStorage.getItem('token')
          },
          params: {
            pagesize: this.commandOfCompany.pagesize,
            current: this.commandOfCompany.current
          }
        }).then((res) => {
        if (res.code === 200) {
          this.commandOfCompany.list = res.data
        } else {
          console.log('获取公司所有设备命令出错')
        }
      })
    },
    // 添加公司命令
    addCommandOfCompany() {
      this.$axios.post(this.PlatformBaseURL + '/device/command/add',
        {
          URL: this.commandOfCompany.command.url,
          description: this.commandOfCompany.command.description,
          company_id: this.$route.query.company_id,
          method: this.commandOfCompany.command.method
        }, {
          headers: {
            satoken: window.localStorage.getItem('token')
          }
        }).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '添加命令成功'
          })
          this.getAllCommandOfCompany()
          this.commandOfCompany.centerDialogVisible = false
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
        }
        this.commandOfCompany.command.description = null
        this.commandOfCompany.command.url = null
      })
    },
    // 删除公司命令
    deleteCommandOfCompany(command_id) {
      this.$axios.post(this.PlatformBaseURL + '/device/command/delete',
        {
          command_id: command_id
        }, {
          headers: {
            satoken: window.localStorage.getItem('token')
          }
        }).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '删除命令成功'
          })
          this.getAllCommandOfCompany()
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
        }
      })
    },
    // 修改公司命令
    updateCommandOfCompany() {
      this.$axios.post(this.PlatformBaseURL + '/device/command/update',
        {
          id: this.commandOfCompany.cur_command_id,
          URL: this.commandOfCompany.cur_command_url,
          description: this.commandOfCompany.command.description,
          company_id: this.commandOfCompany.cur_company_id
        }, {
          headers: {
            satoken: window.localStorage.getItem('token')
          }
        }).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '修改命令成功'
          })
          this.getAllCommandOfCompany()
          this.commandOfCompany.updateVshow = false
        } else {
          this.$message({
            type: 'error',
            message: res.msg
          })
        }
        this.commandOfCompany.command.description = null
        this.commandOfCompany.command.url = null
      })
    },
    // 修改命令彈窗
    changeuc(row) {
      this.commandOfCompany.cur_command_url = row.url
      this.commandOfCompany.cur_company_id = row.company_id
      this.commandOfCompany.cur_command_id = row.id
      this.commandOfCompany.updateVshow = true
    },
    // 修改设备信息
    updateDevice() {
      this.device.from.id = this.device_id
      this.$axios.put(this.PlatformBaseURL + '/device',
        this.device.from,
        {
          headers: {
            satoken: window.localStorage.getItem('token')
          }
        }
      ).then((res) => {
        if (res.code === 200) {
          this.$message({
            type: 'success',
            message: '修改设备成功'
          })
          this.getEquList()
          this.device.Visible = false
          this.device.from.id = null
          this.device.from.name = null
          this.device.from.ip = null
          this.device.from.port = null
          this.device.from.location = null
          this.device.from.description = null
        } else {
          this.$message({
            type: 'error',
            message: '修改设备失败' + res.msg
          })
        }
      })
    }
  }
}

</script>

<style scoped lang="scss">

</style>
